
#include <iostream>
#include <Windows.h>
#include <process.h>
#include <conio.h>
using namespace std;

CRITICAL_SECTION criticalSection; 

DWORD WINAPI Thread1(LPVOID param){
	cout << "Thread is working.....\n";

	EnterCriticalSection(&criticalSection);
	
	cout << "Press any key :)...........\n";
		_getch();

	LeaveCriticalSection(&criticalSection);

	return 0;
}

void main(){
	InitializeCriticalSection(&criticalSection);

	HANDLE hThread1 = CreateThread(NULL, 0, Thread1, NULL, NULL, NULL);
	HANDLE hThread2 = CreateThread(NULL, 0, Thread1, NULL, NULL, NULL);
	
	cout << "Main ...........\n";

	DWORD result = WaitForSingleObject(hThread2, INFINITE);

	DeleteCriticalSection(&criticalSection);
}